#include "board.h"
//#include "sw.h"
//#include "ht1382.h"
#include "timer_1s.h"
//#include "timer_freq.h"
//#include "flash_cpu.h"
//#include "stdlib.h"
//#include "m_kl9.h"
#include "delay.h"
//#include "com_display.h"
#include "watchdog.h"

extern void led_init(void);
extern void cut_io_config(void);
extern void press_io_config(void);
extern void reverse_io_config(void);
extern void power_io_config(void);
extern void sig_time_init(void);
extern void encode_io_config(void);
extern void watchdog_init(void);
//extern void com_display_init(void);
//extern void display_init(void);
//extern void sw_val_init(void);
//extern void fram_init_i2c(void);
//extern void com_lora_init(void);
//extern void lora_init(void);
//extern void ht1382_init(void);

//volatile unsigned char DisplayBusy = 0;
//volatile unsigned char FramBusy = 0;

void board_init(void)
{  
//	FlashCpuParam *ptr = 0;
	
//	unsigned short int sw = 0;
	
	SystemInit();
	
	/* Set the Vector Table base location at 0x08000000 */
	NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);

	com_shell_console_init();
	
	raw_printf("DEZO FRJ V%d.%d build %s\n", YLN_VERSION, YLN_SUBVERSION, __DATE__);
	
	led_init();
	
	cut_io_config();
	
	press_io_config();
	
	encode_io_config();
	
	reverse_io_config();
	
	power_io_config();
	
	sig_time_init();
	
//	flash_cpu_param_get();
//	
//	fram_init_i2c();
//	sw_val_init();
//	ht1382_init();
//	
//	com_lora_init();
//	lora_init();
//	
//	com_display_init();
//	display_init();
	
	TIM2_NVIC_Config();
	TIM2_Config();
	TIM_START;
	
	

//	TIM_FREQ_NVIC_Config();
//	TIM_FREQ_Config();
//	TIM_FREQ_STOP;
	
	watchdog_init();
}

extern void IWDG_Feed(void);

void event_user()
{
	IWDG_Feed();
}

